<?php

class Mailer_g2u{

    var $host       = "mail.g2u.com.pe";
    var $port       = "26";
    var $auth       = true;
    var $username   = "no-reply@g2u.com.pe";
    var $password   = "jcchonor2602";
    
    
    
    function enviarMail($recipient, $subject, $text, $html){
        ini_set("include_path", '/home/cfpljmyz/php:' . ini_get("include_path")  );

        include('Mail.php');
        include('Mail/mime.php');

        $smtpinfo["host"] = $this->host;
        $smtpinfo["port"] = $this->port;
        $smtpinfo["auth"] = $this->auth;
        $smtpinfo["username"] = $this->username;
        $smtpinfo["password"] = $this->password;

        // Constructing the email
        $sender = $smtpinfo["username"];

        //$html = file_get_contents('contents.html');
        //$html = preg_replace('/\\\\/','', $html); //Strip backslashes

        $crlf = "\n";
        $headers = array(
                        'From'          => $sender,
                        'Return-Path'   => $sender,
                        'Subject'       => $subject,
                        'To'       => $recipient,
                        );

        $mime = new Mail_mime($crlf);

        $mime->setTXTBody($text);
        $mime->setHTMLBody($html);

        $body = $mime->get();
        $headers = $mime->headers($headers);

        $mail =& Mail::factory("smtp", $smtpinfo); 

        $mail->send($recipient, $headers, $body);
    }

}
/*
$mail = new Mailer_g2u();

$recipient = "jcarbonel@gmd.com.pe";
$subjet = "Cambio de Correo";
$text = "No HTML";
//$html = file_get_contents('templates/change_mail.php');

ob_start();
include('templates/change_mail.php');
$html = ob_get_contents();
ob_end_clean();

$html = preg_replace('/\\\\/','', $html); //Strip backslashes
$mail->enviarMail($recipient, $subjet, $text, $html);
 
 */
?>